package com.smommo.myapp.initializer;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;

import java.util.HashMap;

public class MyApplicationContextInitializer implements ApplicationContextInitializer {

    //ico容器创建完成执行
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        HashMap<String, Object> myMap = new HashMap<>();
        myMap.put("applicationName","smomo");

        //环境注册属性
        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        MutablePropertySources propertySources = environment.getPropertySources();
        propertySources.addLast(new MapPropertySource("MyApp",myMap));
//        int i=10/0;
    }
}
